def findNumFriend(s):
    s=s.split(',')
    d,result={},[]
    for num in s:
        #计算每一个数字各位数之和
        sumNum=0
        for ch in num:
            sumNum+=int(ch)
        #寻找相同数字和的数字朋友
        if sumNum in d.keys():
            d[sumNum]+=[num]
        else:
            d[sumNum]=[num]
        #基于数字和进行排序
        lst=sorted(d.items(),key=lambda d:d[0])
        for item in lst:
            itemTemp=item[1]
            itemTemp.sort()
            result.append(itemTemp)
        return result
    
if __name__=='__main__':
    s=input("Enter the numbers:")
    result=findNumFriend(s)
    for item in result:
        print(item)